package com.heima.utils.common;

import com.heima.model.wemedia.pojos.WmUser;

/**
 * ThreadLocal 工具类
 */
public class WmThreadLocalUtil {

    private final static ThreadLocal<WmUser> WM_USER_THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 设置用户
     * @param wmUser
     */
    public static void setUser(WmUser wmUser){
        WM_USER_THREAD_LOCAL.set(wmUser);
    }

    /**
     * 得到用户
     * @return
     */
    public static WmUser get(){
        return WM_USER_THREAD_LOCAL.get();
    }

    /**
     * 清理内存防止线程溢出,保证线程安全
     */
    public static void remove(){
        WM_USER_THREAD_LOCAL.remove();
    }
}
